// O(t*n^2*2^n)

#include <iostream>
#include <vector>
#define int long long
using namespace std;

vector<bool> color;
vector<int> nums;

int n, ans;
void dfs(int x)
{
    if (x == n)
    {
        int sum = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i - 1; j >= 0; j--)
            {
                if (color[i] == color[j] && nums[i] == nums[j])
                {
                    sum += nums[i];
                }
                if (color[i] == color[j])
                {
                    break;
                }
            }
        }
        ans = max(ans, sum);
        return;
    }
    dfs(x + 1);
    color[x] = true;
    dfs(x + 1);
    color[x] = false;
}

signed main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        ans = 0;
        nums.clear();
        color.clear();
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            int t;
            cin >> t;
            nums.push_back(t);
            color.push_back(false);
        }
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}